package com.hmdp.controller;


import com.hmdp.domain.dto.Result;
import com.hmdp.domain.entity.ShopType;
import com.hmdp.service.IShopTypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/shop-type")
public class ShopTypeController {
    @Resource
    private IShopTypeService typeService;

    /**
     * 查看所有店铺类型
     * @return
     */
    @GetMapping("list")
    public Result queryTypeList() {
        return typeService.queryTypeList();
    }

    /**
     * 通过类型Id查看店铺
     * @param id
     * @return
     */
    @GetMapping("{id}")
    public Result queryById(@PathVariable Long id){
        return typeService.queryById(id);
    }

    /**
     * 添加店铺类型
     * @param shopType
     * @return
     */
    @PutMapping
    public Result intsert(@RequestBody ShopType shopType){
        return typeService.insert(shopType);
    }

    /**
     * 修改店铺类型
     * @param shopType
     * @return
     */
    @PostMapping
    public Result updateShopType(@RequestBody ShopType shopType){
        return typeService.updateShopType(shopType);
    }
}
